package cn.spring.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import cn.spring.bean.Orders;
import cn.spring.bean.Today;


public interface OrdersMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Orders record);

    int insertSelective(Orders record);

    Orders selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Orders record);

    int updateByPrimaryKey(Orders record);
    
    int updateState(Integer state,Integer id);
    
    List<Orders> selectByState(Integer empId);
    
    int updateTimeAndState(String time,Integer id);
    
    List<Orders> selectToDay(Integer empId);
    
    List<Orders> selectAll(Integer empId);
    
    List<Map<Object,String>> selectOrderById(Integer empId);
    
    List<Map<String, Object>> selectLi(String startTime,String endTime);
    
    List<Today> toDay(Integer empId,String startTime,String endTime);
    
    List<Map<String, Object>> selectMon(String startTime,String endTime);
    
    List<Map<String, Object>> selectLiCom(String startTime,String endTime);
    
    List<Map<String, Object>> selectLiComWan(String startTime,String endTime,Integer empId);
    
    List<Map<String, Object>> selectLiComByWord(String startTime,String endTime,String word);
    
    @Select("select e.*,SUM(case o.state when 2 then 1 else 0 end)as ce,a.`name` as aname from orders as o LEFT JOIN employee as e ON o.emp_id=e.id  LEFT JOIN address AS a ON o.emp_id=a.emp_id  where o.state not in (1,3)  AND a.is_mo=1 and o.ordertime >=#{startTime} and o.ordertime <=#{endTime} and e.`name`LIKE #{word} GROUP BY e.id ORDER BY o.ordertime desc")
    List<Map<String, Object>> selectLiByWord(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("word")String word);
    
    int deleteOrd(Integer id);
    
    List<Today> selectByUserIdMon(Integer eId,String startTime,String endTime);
}